package com.autohammal.save.util;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

public class NameGengerator {
	private static final DateFormat DF = new SimpleDateFormat(
			"yyyy-MM-dd-HH-mm-ss-SSS");

	public static String generate(Style style) {
		switch (style) {
		case TIME:
			return DF.format(new Date());
		case UUID:
			return UUID.randomUUID().toString();
		case TIME_UUID:
			return DF.format(new Date()) + "_" + UUID.randomUUID().toString();
		default:
			return UUID.randomUUID().toString() + "_" + DF.format(new Date());
		}

	}

	public static String generate(Class<?> clz, Style style) {
		String lastfix = "";
		switch (style) {
		case TIME:
			lastfix = DF.format(new Date());
		case UUID:
			lastfix = UUID.randomUUID().toString();
		case TIME_UUID:
			lastfix = DF.format(new Date()) + "_"
					+ UUID.randomUUID().toString();
		default:
			lastfix = UUID.randomUUID().toString() + "_"
					+ DF.format(new Date());
		}
		return clz.getName() + "-" + lastfix;

	}

	public static String generate(SaveType type, Style style) {
		String lastfix = "";
		switch (style) {
		case TIME:
			lastfix = DF.format(new Date());
		case UUID:
			lastfix = UUID.randomUUID().toString();
		case TIME_UUID:
			lastfix = DF.format(new Date()) + "_"
					+ UUID.randomUUID().toString();
		default:
			lastfix = UUID.randomUUID().toString() + "_"
					+ DF.format(new Date());
		}
		return type.toString() + "_" + lastfix;

	}

	public enum SaveType {
		MONITOR, TARGET
	}

	public enum Style {
		TIME, UUID, TIME_UUID, UUID_TIME
	}
}
